<%@ page language="java" contentType="text/html; charset=utf-8"  pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>

<html>
<head>
    <title>账单打印</title>
    <script src="http://cdn.bootcss.com/jquery/1.11.0/jquery.min.js"></script>
    <style>
        table tbody td {

            border: 1px solid black;
            text-align: center;
        }

        table tbody tr .rigth {
            text-align: right;
        }

        table tbody tr .co {
            text-align: left;
        }
        table tfoot  .tfoot td {
            border: 1px solid black;
        }

    </style>
    <style media=print>
        .Noprint{display:none;}
        .PageNext{page-break-after: always;}
    </style>
    <script language=javascript>
        function printsetup() {
            // 打印页面设置
            wb.execwb(8, 1);
        }
        function printpreview() {
            // 打印页面预览 　
            wb.execwb(7, 1);
        }
        function printit() {


            javascript:window.print()

        }
    </script>

    <script>

        // 格式化时间

        /** 数字金额大写转换(可以处理整数,小数,负数) */
        var digitUppercase = function (n) {
            var fraction = ['角', '分'];
            var digit = [
                '零', '壹', '贰', '叁', '肆',
                '伍', '陆', '柒', '捌', '玖'
            ];
            var unit = [
                ['元', '万', '亿'],
                ['', '拾', '佰', '仟']
            ];
            var head = n < 0 ? '欠' : '';
            n = Math.abs(n);
            var s = '';
            for (var i = 0; i < fraction.length; i++) {
                s += (digit[Math.floor(n * 10 * Math.pow(10, i)) % 10] + fraction[i]).replace(/零./, '');
            }
            s = s || '整';
            n = Math.floor(n);
            for (var i = 0; i < unit[0].length && n > 0; i++) {
                var p = '';
                for (var j = 0; j < unit[1].length && n > 0; j++) {
                    p = digit[n % 10] + unit[1][j] + p;
                    n = Math.floor(n / 10);
                }
                s = p.replace(/(零.)*零$/, '').replace(/^$/, '零') + unit[0][i] + s;
            }
            return head + s.replace(/(零.)*零元/, '元')
                    .replace(/(零.)+/g, '零')
                    .replace(/^整$/, '零元整');
        };


        $(function(){

         $('#zjdx span') .text(digitUppercase($('#zj span').text()))
               if($('#dzt').text()==0){
                   $('#dzt').text("草稿")
               }else if($('#dzt').text()==1){
                   $('#dzt').text("待审核")
               }else if($('#dzt').text()==2){
                   $('#dzt').text("已审核")
               }else if($('#dzt').text()==3){
                   $('#dzt').text("已出库")
               }else {
                   $('#dzt').text("其他")
               }



           /* var d = new Date($('#time').text());
            var formatIt = d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + (d.getDate()-1) + ' ' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds();
            $('#time').text(formatIt)*/
            if($('#fenlei').text()==1 || $('#fenlei').text()==2){
                   $('#fenlei').text("(退货)")
               }else{
                   $('#fenlei').text("")
               }

        })




    </script>


</head>
<body>
<div style='width:640px;text-align: right;' class='Noprint'>
    <OBJECT id=wb height=0 width=0 classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 name=wb></OBJECT>
    <INPUT class='input' onclick=javascript:printit() type=button value=打印 name=button_print/>
    <INPUT class='input' onclick=javascript:printsetup(); type=button value=打印页面设置 name=button_setup/>
    <INPUT class='input' onclick=javascript:printpreview(); type=button value=打印预览 name=button_show/>
</div>

<table width="650" style="margin: 0 auto;border-collapse: collapse;">
    <thead>
    <tr>
        <th colspan="6" style="text-align: center;font-size:x-large;">苏格马可销售单<span id="fenlei">${printList.danList[0].fenlei}</span></th>
    </tr>
    <tr>
        <td colspan="6" style="text-align: right;"><span id="dzt">${printList.danList[0].state}</span> NO:${printList.danList[0].chukudanhao}</td>
    </tr>
    <tr>
        <td colspan="3">电话/传真:${printList.danList[0].phone}</td>

        <td colspan="3">汇款账号:${printList.danList[0].zhanghuOne};</td>
    </tr>
    <tr>
        <td colspan="6">${printList.danList[0].zhanghuTwo};${printList.danList[0].zhanghuTree}
        </td>


    </tr>
    <tr>
        <td colspan="3">客户:${printList.danList[0].wldwName}</td>
        <td colspan="2">电话:${printList.danList[0].khphone}</td>
        <td colspan="2" style="text-align: right;">日期:<span  id="time">${printList.danList[0].shijian}</span></td>
    </tr>
    </thead>
    <tbody>
    <tr>
        <td>序号</td>
        <td>品名</td>
        <td>数量</td>
        <td>单价</td>
        <td>金额</td>
        <td>颜色明细</td>
    </tr>


    <c:forEach items="${printList.proList}" var="p" varStatus="loop" >
        <tr>
            <td>${loop.index+1}</td>
            <td>${p.productName}</td>
            <td class="rigth">${p.kshuliang}</td>
            <td class="rigth">${p.danjia}</td>
            <td class="rigth">${p.kzongjia}</td>
            <td class="co">${p.colorArrayString}</td>
        </tr>

    </c:forEach>

    </tbody>
    <tfoot>
    <tr class="tfoot">
        <td colspan="2">总数:${printList.danList[0].zshuliang}</td>
        <td colspan="2" id="zj" >总额:<span>${printList.danList[0].zongjia}</span></td>
        <td colspan="2" id="zjdx">总额(大写):<span></span></td>
    </tr>
    <tr class="tfoot">
        <td colspan="2">累计金额:${printList.danList[0].amount}</td>
        <td colspan="2" >累计付款:<span>${printList.danList[0].yifu}</span></td>
        <td colspan="2" >当前欠款:${printList.danList[0].qiankuan}</td>
    </tr>
    <tr>
        <td colspan="2">制单人:${printList.danList[0].zhidanrenName}</td>
        <td colspan="2">审核人:${printList.danList[0].shenherenName}</td>
        <td colspan="2">出库人:${printList.danList[0].chukurenName} 客户签字:</td>
    </tr>
    <tr>
        <td colspan="6" style="font-size: small">
            购货方收到我司货品,请在3日内将此单签字后拍照回传,逾期未回传视同已确认收货;如收到的货品有质量问题,请在7日内与我司联系,逾期恕不负责;双方如有纠纷,由供货方经营地人民法院解决
        </td>
    </tr>
    </tfoot>
</table>
</body>
</html>
